import { mapActions } from 'vuex';

export default {
  methods: {
    ...mapActions(['tongyong']),
    tankuang(val, code) {
      if (code == 200) {
        this.$message({
          type: 'success',
          message: val + '成功!',
        });
      } else {
        this.$message({
          type: 'error',
          message: val + '失败!',
        });
      }
    },
    deleteDataTy(obj, myval) {
      return this.$confirm('此操作将永久' + myval + '该文件, 是否继续?', '提示', {
        confirmButtonText: myval,
        cancelButtonText: '取消',
        type: 'warning',
        center: true,
      })
        .then(() => {
          return this['tongyong']({
            name: obj.name,
            data: obj.data,
          })
            .then(res => {
              this.tankuang(myval, res.data.code);
              return res;
            })
            .catch(() => {
              this.$message({
                type: 'error',
                message: myval + '失败',
              });
            });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消' + myval,
          });
        });
    },
  },
};
